package com.rj2002.ctrl;

import java.io.UnsupportedEncodingException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rj2002.dao.GoodstypeMapper;
import com.rj2002.dao.LunboMapper;
import com.rj2002.dao.UserMapper;
import com.rj2002.pojo.Goodstype;
import com.rj2002.pojo.Lunbo;
import com.rj2002.pojo.User;
import com.rj2002.util.ResultUtil;

@Controller
@RequestMapping("/admin")
public class AdminPageCtrl {

	@Autowired
	private UserMapper userMapper;

	@Autowired
	private GoodstypeMapper typeMapper;
	
	@Autowired
	private LunboMapper lunbotu;
	
	@RequestMapping("/getGoodsList")
	public String getGoodsList(Model model) {
		return "GoodsList";
	}
	
	@RequestMapping("/showLunBo")
	public String showLunBo(Model model) {
		return "lunbo";
	}
	
	@RequestMapping("/addLunBo")
	public String addLunBo(Model model) {
		return "addLunBo";
	}
	
	@RequestMapping("/lunbo/edit")
	public String lunboEdit(int id,HttpServletRequest request,Model model) {
		Lunbo lunbo = lunbotu.selectByPrimaryKey(id);
		model.addAttribute("lunbo", lunbo);
		return "lunboEdit";
	}

	@RequestMapping("/getGoodsType")
	public String getGoodsType(Model model) {
		return "GoodsTypeJsp";
	}

	@RequestMapping("/goodstypeshowadd")
	public String goodstypeshowadd(Model model) {
		return "GoodTypeAdd";
	}

	@RequestMapping("/userList/edit")
	public String userList_edit(Model model, int id) {
		User user = userMapper.selectByPrimaryKey(id);
		model.addAttribute("user", user);
		return "userListEdit";
	}

	/**
	 * 原先的会员管理改为个人信息管理
	 * 
	 * @return
	 */
	@RequestMapping("/personMsg")
	public String personMsg() {
		return "personMsg";
	}

	@RequestMapping("/userListJsp2")
	public String userListJsp2() {
		return "userList2";
	}
	
	@RequestMapping("/getAllOrder")
	public String getAllOrder() {
		return "Order";
	}

	@RequestMapping("/addUserJSP")
	public String addUserJSP() {
		return "addUserJSP";
	}

}
